#include <iostream>
#include <string>
#include <cstdio>

class S {
    private:
        std::string name_;

    public:
        S() { }

        S(std::string &name) {
            printf("[ S ] name: %p\n", static_cast<void *>(&name));
            name_ = name;
            printf("[ S ] name_: %p\n", static_cast<void *>(&name_));
        }

        S& setName(std::string name) const {
            name_ = name;
            return this;
        }

        std::string Name() const { return name_; }
};

S b() {
    return {};
}

S& c(S &s) {
    return s;
}

int main() {
    std::string name("123");
    /*
    printf("[ MAIN ] name: %p\n", static_cast<void *>(&name));
    S s(name);

    std::string n = s.Name();
    printf("[ MAIN ] name: %p\n", static_cast<void *>(&n));


    std::cout << "s.name: " << n << std::endl;
    */

    S s = b();
    c(s).setName(name);
    printf("[ MAIN ] s: %p\n", static_cast<void *>(&s));

    S s2 = b();
    printf("[ MAIN ] s2: %p\n", static_cast<void *>(&s2));

    return 0;
}
